package com.iotteam.androidbase.moudules.sensor_add.view;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.iotteam.androidbase.R;
import com.iotteam.androidbase.base.ToolbarActivity;
import com.iotteam.androidbase.commen.utils.ToastUtil;
import com.iotteam.androidbase.moudules.sensor_add.presenter.AddSensorPresenterCompl;
import com.iotteam.androidbase.moudules.sensor_add.presenter.IAddSensorPresenter;

/**
 * Created by lidechen on 5/5/17.
 */

public class AddSensorActivity extends ToolbarActivity implements IAddSensorView, View.OnClickListener {

    private TextView mIdText;
    private TextView mCheckText;
    private Button mBindingBtn;
    private IAddSensorPresenter mAddSensorPresenter;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_add_sensor;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mAddSensorPresenter = new AddSensorPresenterCompl(this);

        mIdText = (TextView) findViewById(R.id.edit_text_terminal_id);
        mCheckText = (TextView) findViewById(R.id.edit_text_check_word);
        mBindingBtn = (Button) findViewById(R.id.btn_binding);

        mBindingBtn.setOnClickListener(this);
    }

    @Override
    public String getSensorID() {
        return mIdText.getText().toString().trim();
    }

    @Override
    public String getCheckword() {
        return mCheckText.getText().toString().trim();
    }

    @Override
    public void showError(String err) {
        ToastUtil.showLong(err);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if(id == R.id.btn_binding){
            mAddSensorPresenter.binding();
        }
    }
}
